package schedule.model;

public class milTimeSchedule {

	private int[] milStartTime = new int[100];
	private int[] milEndTime = new int[100];
	int freeSlot = 0;
	private int minMeetTime = 2;
	
	public void setMinimumMeetTime (int minTime)
	{
		minMeetTime = minTime;	
	}
	public int getMeetTime()
	{
		return minMeetTime;
	}
	//cant put in times out of range, endTime less than a start time 
	public void setAvailable(int startTime, int endTime)
	{
		if (startTime>endTime){
			milStartTime[freeSlot] = startTime;
			milEndTime[freeSlot] = endTime;
			freeSlot++;
		}
		
	}
	
	public int getNumSlots()
	{
		return freeSlot;
	}
	
	public int getStart(int time)
	{
		return milStartTime[time];
	}
	
	public int getEnd(int time)
	{
		//return milEndTime[time] + 15 here?
		return milEndTime[time];
	}
	public int convertToMin(int time)
    {
		int MinutesTimeAfterEightOclock = 0;
		int minTime;
		int hours, minHours;
		int minutes;
   
		hours = time/100;
		minutes = time % 100;
		minHours = hours * 60; //gives whole hour minute value
   
		minTime = minHours + minutes; //adds minute value based on hours to left over minutes 
		MinutesTimeAfterEightOclock = minTime - 480; // subtracts 8 o'clock (480 minutes) from minute version of time input 
		return MinutesTimeAfterEightOclock;
    }
	public int milTimeToSlot(int milTime)
    {
        	int slot = 0;
        	int min;
        	
        	min = convertToMin(milTime);        	
        	slot = min/15;
        	
        	return slot;
        	
    }
    public booleanSchedule getBoolSchedule(){
        	booleanSchedule schedule = new booleanSchedule();
        	for (int i=0;i<freeSlot;i++){
    			int startTime = getStart(i);			
    			int endTime = getEnd(i);
    			int startMin =convertToMin(startTime);
    			int endMin = convertToMin(endTime);    			
    			for (int count = startMin/15; count<endMin/15; count++){
    				schedule.setAvailable(count);
    			}    			
    		}
        	return schedule;
    }
       

}
